import {apiThreeUser} from "../api/index"
const Client = {
    client_id:"9b108c68d132208a8822c8bf9b32c260728fe41d883b88b9090d18774c149088",
    client_secret:"e3289c2c28e1586ff4cb8411c7842f2ba152ad3fa3eff27d42cfb5dcf8f89716",
    redirect_uri:"http://localhost:8080/login"
};
export const getcode = ()=>{
    let url = `https://gitee.com/oauth/authorize?client_id=${Client.client_id}&redirect_uri=${Client.redirect_uri}&response_type=code`;
    window.location.href = url;
}
export const analysis = ()=>{
    let params = window.location.search.slice(1).split('&')[0].split('=')[1];
    return params;
}
export const getUser = async (cellback)=>{
    let code = analysis();
    if(code){
        let res = await apiThreeUser({code});
        if(res.data.code===200){
            // console.log(res.data.data);
            // console.log(res.data.token);
            cellback(res.data.data,res.data.token)
        }
    }
}